//
//  SDQrCodeViewController.m
//  skinDetection
//
//  Created by  liangzhun on 2018/10/31.
//  Copyright © 2018年  liangzhun. All rights reserved.
//

#import "SDQrCodeViewController.h"
#import "SDDetectionViewController.h"
#import "SDDetectionDataModel.h"
#import "SDQuestionnaireViewController.h"
@interface SDQrCodeViewController ()

@end

@implementation SDQrCodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.QrView.layer.masksToBounds = YES;
    self.QrView.layer.cornerRadius = 5.0;
    [self presentView];
    
    [self.beginBtn handleControlEvent:UIControlEventTouchUpInside withBlock:^{
        
        [SDDetectionDataModel shareInstance].userModel = SDAppDelegate.userModel;
         [self beginDetection];
        
    }];
    //根据链接生成对应的二维码
    self.qrImage.image = [SDMethodTool getQrCodeImageWithText:@"https://itunes.apple.com/cn/app/%E4%BD%91%E8%9C%9C/id1245491402?mt=8" Width:170];
    
}
//进入检测页面
- (void)beginDetection
{
    SDDetectionViewController *vc = [SDMethodTool getViewControlWithIdentifier:NSStringFromClass([SDDetectionViewController class])];
    
    [self.navigationController pushViewController:vc animated:YES];
    [self dismissView];
    
}
//显示二维码
- (void)presentView
{
    self.QrView.alpha = 0.2;
    [UIView animateWithDuration:0.1 animations:^{
        self.QrView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
}
//隐藏二维码
- (void)dismissView
{

    [UIView animateWithDuration:0.2 animations:^{
        self.QrView.alpha = 0.1;
    } completion:^(BOOL finished) {
        [self.view removeFromSuperview];
        [self removeFromParentViewController];
    }];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self dismissView];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
